using System;
using System.Windows.Forms;

namespace ShadeTree.Binding.Elements
{
    public delegate object CoerceFunction(Accessor property, string rawValue);

    public delegate string FormatValue(object rawValue);

    public class TextboxElement : TextEditingElement<TextBox>
    {
        public TextboxElement(Accessor accessor, TextBox control) : base(accessor, control)
        {
            control.GotFocus += control_GotFocus;
        }

        private void control_GotFocus(object sender, EventArgs e)
        {
            BoundControl.SelectAll();
        }


        protected override void setTheMaximumLength(int length)
        {
            BoundControl.MaxLength = length;
        }

        protected override void setTheAlignmentToTheRight(TextBox control)
        {
            control.TextAlign = HorizontalAlignment.Right;
        }

        protected override void postFocus()
        {
            BoundControl.SelectAll();
        }
    }
}